import 'package:base/resources/base_asserts.dart';
import 'package:base/resources/base_colors.dart';
import 'package:base/resources/base_constants.dart';
import 'package:flutter/material.dart';

class ErrorView extends StatelessWidget {
  final String? error;

  final GestureTapCallback? onTap;

  final String? errorImage;

  ErrorView({this.error, this.errorImage, this.onTap, Key? key})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: onTap,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Image.asset(
              errorImage ?? BaseAssets.error,
              height: 150,
              package: errorImage == null ? BaseConstants.PACKAGE : null,
            ),
            Text(
              error ?? "异常",
              textAlign: TextAlign.center,
              style: TextStyle(
                color: BaseColors.textColor,
                fontSize: 12,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
